import random

# print("请输入账号:")
# username = input()
# if username == 'wang':
#     print("登录成功")
# elif username == 'admin':
#     print("管理员账号")
# else:
#     print("账号不存在")

age = 18
assert age == 18, "她竟然不是18岁"

animals = ['cat', 'dog', 'pig']
for animal in animals:
    print(animal)

# 全闭区间
number = random.randint(1, 10)
print(number)

numbers = []
while len(numbers) < 20:
    numbers.append(random.randint(1, 10))
print(numbers, "len = {}".format(len(numbers)))

numbers2 = []
for i in range(20):
    numbers2.append(random.randint(1, 20))
print(numbers2, "len = {}".format(len(numbers2)))

for i in numbers2:
    if i % 2 == 0:
        print(i, end=" ")
    else:
        continue
else:
    print("全是偶数")

print("----------- 构建推导式 ---------------")
# 构建推导式
list1 = list(range(10))
list2 = [item * 2 for item in list1]
print(list2)
dict2 = {item: '666' for item in list1}
print(dict2)
tuple2 = (item * 2 for item in list1)  # 生成器
print(tuple2)
tuple3 = tuple(list1)
print(tuple3)
tuple4 = tuple(tuple2)
print(tuple4)
tuple5 = tuple(tuple2)
print(tuple5)

"""
输出：
cat
dog
pig
3
[3, 10, 5, 1, 7, 8, 3, 2, 5, 4, 2, 8, 1, 3, 2, 2, 2, 4, 10, 1] len = 20
[7, 15, 9, 10, 16, 20, 11, 18, 7, 15, 3, 4, 4, 1, 15, 8, 16, 18, 18, 5] len = 20
10 16 20 18 4 4 8 16 18 18 全是偶数
----------- 构建推导式 ---------------
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
{0: '666', 1: '666', 2: '666', 3: '666', 4: '666', 5: '666', 6: '666', 7: '666', 8: '666', 9: '666'}
<generator object <genexpr> at 0x00000212E45A3270>
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
(0, 2, 4, 6, 8, 10, 12, 14, 16, 18)
()
"""